var t = getApp(), e = require("../../../component/WxNotificationCenter/WxNotificationCenter.js");

Page({
    data: {
        pageNo: 1,
        index: 0,
        listDatas: []
    },
    loadData: function(e) {
        var a = this, n = a.data.pageNo;
        if (e) n = 1; else if (a.data.total == a.data.listDatas.length) return void wx.hideNavigationBarLoading();
        t.network.post({
            url: t.url.listSendOrderUser,
            params: {
                sendOrderId: a.data.orderId,
                pageNo: a.data.pageNo,
                pageSize: 10
            },
            before: function() {
                wx.showNavigationBarLoading();
            },
            success: function(o) {
                if (1 == o.data.result) {
                    var s = [];
                    e || (s = a.data.listDatas), s = s.concat(o.data.data.sendOrderUsers), console.log(s), 
                    n += 1, a.setData({
                        total: o.data.data.total,
                        listDatas: s,
                        pageNo: n
                    });
                } else t.util.showToast(o.data.message);
            },
            fail: function() {
                t.util.showToast("获取数据失败");
            },
            complete: function() {
                wx.hideNavigationBarLoading(), wx.stopPullDownRefresh();
            }
        });
    },
    select: function(a) {
        t.network.post({
            url: t.url.listSendOrderUser,
            params: {
                sendOrderId: 20,
                sendOrderUserId: a.userId
            },
            before: function() {
                wx.showLoading({
                    title: "正在提交"
                });
            },
            success: function(n) {
                1 == n.data.result ? wx.showModal({
                    title: "选定成功",
                    content: "",
                    success: function(t) {
                        t.confirm && (wx.showToast({
                            title: "选定成功"
                        }), e.postNotificationName("didSelectOrderClient", a), setTimeout(function() {
                            wx.navigateBack({});
                        }, 1200));
                    }
                }) : t.util.showToast(n.data.message);
            },
            fail: function() {
                t.util.showToast("获取数据失败");
            },
            complete: function() {
                wx.hideLoading();
            }
        });
    },
    bindCall: function(t) {
        var e = t.currentTarget.dataset.phone;
        wx.makePhoneCall({
            phoneNumber: e
        });
    },
    bindChat: function() {},
    bindSelect: function(t) {
        var e = this, a = t.currentTarget.dataset.name, n = t.currentTarget.dataset.userid, o = t.currentTarget.dataset.role, s = t.currentTarget.dataset.useraccesstoken, i = t.currentTarget.dataset.avatar, r = t.currentTarget.dataset.phone;
        wx.showModal({
            title: "提示",
            content: "确定选定" + o + a + "?",
            success: function(t) {
                if (t.confirm) {
                    var d = {
                        userId: n,
                        index: e.data.index,
                        selectUserName: a,
                        selectUserAccessToken: s,
                        selectUserRole: o,
                        userAvatar: i,
                        selectUserPhone: r
                    };
                    e.select(d);
                } else t.cancel;
            }
        });
    },
    onLoad: function(t) {
        this.setData({
            orderId: t.orderId,
            index: t.index
        }), this.loadData(!0);
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        wx.showNavigationBarLoading(), this.loadData(!1);
    }
});